Add tracing configuration docs - #55758
Draft
rosebyte wants to merge 1 commit into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new documentation article that explains how to register and configure the .NET 11 distributed tracing configuration APIs, and wires the new article into existing navigation for diagnostics/distributed tracing.
Changes:
- Adds a new “Configure distributed tracing” article covering rule schema, matching, precedence, scopes, reload behavior, and invalid configuration behavior.
- Adds runnable C# and Visual Basic sample projects plus an
appsettings.jsonexample used by the article. - Links the new article from the distributed tracing overview and the tools/diagnostics TOC.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/navigate/tools-diagnostics/toc.yml | Adds a TOC entry for the new configuration article under distributed tracing. |
| docs/core/diagnostics/distributed-tracing.md | Adds a link to the new configuration article from the distributed tracing overview. |
| docs/core/diagnostics/distributed-tracing-configuration.md | New article documenting tracing listener registration and configuration rules, including samples and schema guidance. |
| docs/core/diagnostics/snippets/distributed-tracing-configuration/appsettings.json | Adds a JSON configuration example referenced from the article. |
| docs/core/diagnostics/snippets/distributed-tracing-configuration/csharp/TracingConfiguration.csproj | Adds a runnable C# console sample project targeting net11.0. |
| docs/core/diagnostics/snippets/distributed-tracing-configuration/csharp/Program.cs | Adds the C# runnable sample used in the article. |
| docs/core/diagnostics/snippets/distributed-tracing-configuration/vb/TracingConfiguration.vbproj | Adds a runnable VB console sample project targeting net11.0. |
| docs/core/diagnostics/snippets/distributed-tracing-configuration/vb/Program.vb | Adds the VB runnable sample used in the article. |
Suppressed comments (1)
docs/core/diagnostics/distributed-tracing-configuration.md:144
- This xref uses the
System.Diagnosticsnamespace, butActivitySourceFactoryis inMicrosoft.Extensions.Diagnostics.Tracing. As written, the xref likely won't resolve.
Use <xref:System.Diagnostics.ActivitySourceFactory.Create*> when you want the dependency injection container to manage the source and its tracing listeners. A factory's listeners ignore local sources created by a different factory. Rules in `EnabledTracing` apply to both source types.
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| - Configure the listener's sampling and notification delegates through <xref:Microsoft.Extensions.Diagnostics.Tracing.ActivityListenerBuilder>. The tracing infrastructure owns `ShouldListenTo`, source subscriptions, and the listener lifetime. | ||
| - Call <xref:Microsoft.Extensions.Diagnostics.Tracing.TracingBuilderConfigurationExtensions.AddConfiguration*> with the configuration section that contains the rules. For a section named `Tracing`, pass `configuration.GetSection("Tracing")`. | ||
|
|
||
| The [complete sample](#run-the-sample) shows all three calls. A .NET host activates tracing subscriptions when the host starts. If you use dependency injection without a host, resolve the registered <xref:System.Diagnostics.ActivitySourceFactory> to construct the listeners and activate their subscriptions. The complete sample resolves the factory directly. |
|
|
||
| The configuration loader silently ignores a leaf value that isn't a valid Boolean. It also ignores unknown or malformed sections that don't match the supported schema. Check key names carefully because these cases don't produce an exception. | ||
|
|
||
| A source expression can contain at most one `*` wildcard. A rule with more than one wildcard throws an <xref:System.ArgumentException> when the rule is materialised, either during app startup or after configuration reload. For programmatic rules, <xref:Microsoft.Extensions.Diagnostics.Tracing.ActivitySourceScopes.None> also causes an <xref:System.ArgumentOutOfRangeException>. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds documentation for the .NET 11 distributed tracing configuration APIs and links it from the distributed tracing overview and diagnostics table of contents.
Content sources
The existing .NET 11 What's New entry remains unchanged.
Related to dotnet/runtime#129380.
Internal previews
Build report